package com.pda.xinma.dialog;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.pda.xinma.R;
import com.wangshen.base.dialog.base.BaseDialog;


import java.util.Objects;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class AffirmDialog extends BaseDialog {
    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_confirm)
    TextView tvConfirm;
    OnConfrim onConfrim;
    public AffirmDialog(@NonNull Context context, OnConfrim onConfrim) {
        super(context);
        this.onConfrim=onConfrim;
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
        Objects.requireNonNull(this.getWindow()).setBackgroundDrawableResource(android.R.color.transparent);
        getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
        getWindow().setGravity(Gravity.CENTER);
    }

    @Override
    public void initData() {

    }


    public void show(String title) {
        super.show();
        tvContent.setText(title);
    }

    @Override
    public int getView() {
        return R.layout.dialog_affirm;
    }

    @OnClick({R.id.tv_cancel, R.id.tv_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_cancel:
                dismiss();
                break;
            case R.id.tv_confirm:
                dismiss();
                onConfrim.onConfrim();
                break;
        }
    }
    public interface OnConfrim{
       void onConfrim();
    }
}
